<style scoped>

</style>

<template>
  <div>
    <h1>Home</h1>
    <h1>Hey {{ username }} ! Welcome to my website!</h1>
    <button @click="logout">退出登录</button>
  </div>

</template>

<script setup>
import { onMounted, ref } from 'vue';
import { routerKey, useRouter } from 'vue-router';
const router = useRouter()

let username = ref('')
onMounted(() => {
    username.value = window.sessionStorage.getItem('username')
    
})
function logout() {
    window.sessionStorage.removeItem('username')
    router.push('/login')
}

</script>

